# from django.http import HttpResponse
#
#
# class MyMd(object):
#     def __init__(self,get_response):
#         self.get_response = get_response
#     def __call__(self, request):
#         if hasattr(self, 'process_request'):
#             response = self.process_request(request)
#             response = response or self.get_response(request) #视图函数
#         if hasattr(self, 'process_response'):
#             response = self.process_response(request, response)
#         return response
#     def process_request(self,request):
#         print("来了")
#         return HttpResponse("哈哈哈")
#
#     def process_response(self,request, response):
#         print("走了")
#         return HttpResponse("fffff")

from django.utils.deprecation import MiddlewareMixin

class MyMd(MiddlewareMixin):
    def process_request(self, request):
        print("来了")
    def process_response(self, request, response):
        print("走了")
